function Vote(options)
{
    this.options = $.extend(true, Map.defaults, options);
    this.voteUp = function(targetId, targetType) {	
	if (!targetId || !targetType) {	    
	    showStatusMessage("Тип не указан", "error");
	    return;
	}
	this.accept(1, targetId, targetType);
    }
    this.voteDown = function(targetId, targetType) {
	if (!targetId || !targetType) {
	    showStatusMessage("Тип не указан", "error");
	    return;
	}
	this.accept(-1, targetId, targetType);
    }
    this.accept = function(direction, targetId, targetType) {
	$.get("/ajax/vote",{
	    direction : direction, 
	    targetId: targetId, 
	    targetType:targetType
	}, this.render, "json");
    }
    this.render = function(data){
	if (data.error !== undefined) {
	    showStatusMessage(data.error, "error");
	    return;
	}
	showStatusMessage("Ваш голос учтен", "good");
	var id = "#" + data.targetType + "_" + data.targetId;
	if ($(id).length) {
	    if ($(id).find(".rating:first").length) {
		$(id).find(".rating:first").html(data.rating);
	    }
	}
    }
}
